package com.wzn;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class ForUpdateTest2 {
	public static void main(String args[]) throws ClassNotFoundException, SQLException, InterruptedException {
		String driver = "com.mysql.jdbc.Driver";
		String connectionURL = "jdbc:mysql://127.0.0.1/writedown?useSSL=false";
		String username = "root";
		String password = "root";
		Class.forName(driver);
		Connection con = DriverManager.getConnection(connectionURL, username, password);

		String sql = "update writedown.us_userinfo set password=? where id=2";

		PreparedStatement pre = con.prepareStatement(sql);
		pre.setString(1, "798697");

		int i = pre.executeUpdate();
		System.out.println("执行结果:" + i);

		System.out.println("主线程结束");
		
		Thread.sleep(30000);

		pre.close();
		con.close();

	}

}
